package com.hr.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hr.entity.MajorChange;
import com.hr.entity.R;
import com.hr.service.MajorChangeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@RestController
@RequestMapping("/majorChange")
public class MajorChangeController {
    @Autowired
    private MajorChangeService service;

    /**
     * 保存/修改
     * @param majorChange
     * @return
     */
    @PostMapping("/save")
    public R save(
            @RequestBody
            MajorChange majorChange){
        boolean save = service.save(majorChange);
        return save ? R.ok("保存成功"):R.fail("保存失败");
    }

    /**
     * 分页查询
     * @return
     */
    @GetMapping("/queryList")
    public Page<MajorChange> queryList(Page<MajorChange> page){
       page= service.queryList(page);
       return page;
    }

    /**
     * 单值查询
     * @param mchid
     * @return
     */
    @GetMapping("/queryById")
    public MajorChange queryById(Integer mchid){
        MajorChange majorChange = service.queryById(mchid);
        return majorChange;
    }

    /**
     * 条件查询
     * @param majorChange
     * @return
     */
    @GetMapping("/queryListByReason")
    public List<MajorChange> queryListByReason(MajorChange majorChange){
        List<MajorChange> list = service.queryListByReason(majorChange);
        return list;
    }
}
